
import Vue from 'vue';
import VueRouter from "vue-router";
Vue.use(VueRouter);

import zh from "./zh"
import wf from "./wf"
import zhaoxi from "./zhaoxi"
import sidiao from "./sidiao"


// 创建router对象
let routes = [...zh, ...wf, ...zhaoxi, ...sidiao
    // {
    //     path:"*",
    //     conponent:NotFound
    // }
];

let router = new VueRouter({
    mode: "history",
    routes
})


// 前置全局守卫
router.beforeEach((to, from, next) => {
    if (to.matched.requireAuth) {
        if (localStorage.getItem("username")) {
            next();
        } else {
            next("/Login?aaa=" + to.path);//路由中的query传值
        }
    } else {
        next();
    }
});

// 全局的后置守卫
router.afterEach((to, from) => {
    // console.log("全局后置守卫");
    // console.log("to",to);
    // console.log("from",from);
})



export default router;

